package main

import "fmt"

func isPalindrome(s string) bool {
	i, j := 0, len(s)-1
	for i < j {
		for i < j && !isChar(rune(s[i])) {
			i++
		}
		for i < j && !isChar(rune(s[j])) {
			j--
		}
		if i >= j {
			break
		}
		if !isSame(rune(s[i]), rune(s[j])) {
			return false
		}
		i++
		j--
	}
	return true
}

func isChar(c rune) bool {
	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
}

func isSame(c1, c2 rune) bool {
	if c1 == c2 {
		return true
	}
	if c1 >= 'a' && c1 <= 'z' && c2-c1 == 'A'-'a' {
		return true
	}
	if c1 >= 'A' && c1 <= 'Z' && c2-c1 == 'a'-'A' {
		return true
	}
	return false
}

func main() {
	fmt.Println(isPalindrome("Amanaplanacanal: Panama"))
}
